<!doctype html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title th:text="${platformName}+'任务调度平台'"></title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" th:href="@{../static/layui/images/logo.png}">
    <link rel="stylesheet" th:href="@{../static/layui/css/font.css}">
    <link rel="stylesheet" th:href="@{../static/layui/css/login.css}">
    <link rel="stylesheet" th:href="@{../static/layui/css/xadmin.css}">
    <script th:src="@{../static/layui/js/jquery.min.js}"></script>
    <script th:src="@{../static/js/CommonUtil.js}"></script>
    <script th:src="@{../static/js/kconfig.js}"></script>
    <script th:src="@{../static/layui/js/md5.js}" charset="utf-8"></script>
    <script th:src="@{../static/layui/lib/layui/layui.js}" charset="utf-8"></script>
    <script th:src="@{../static/layui/js/xadmin.js}"></script>

    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="index">
<!-- 顶部开始 -->
<div class="container">
    <div class="logo">
        <a href="/index"><span th:text="${platformName}"></span>任务调度平台</a></div>
    <div class="left_open">
        <a><i title="展开左侧栏" class="iconfont">&#xe699;</i></a>
    </div>
    <ul class="layui-nav right" lay-filter="">
        <li class="layui-nav-item">
            <a href="javascript:;" id="currentUserRealName"></a>
            <a href="javascript:;"></a>
            <dl class="layui-nav-child">
                <!-- 二级菜单 -->
                <dd>
                    <!--
                                        <a onclick="xadmin.open('个人信息',api.user.user_person_html,300, 300,true)">个人信息</a></dd>
                    -->
                    <a href="javascript:;" id="userPersonalDetail">个人信息</a></dd>
                <dd>
                    <a href="javascript:;" id="loginOut">退出</a></dd>
            </dl>
        </li>
    </ul>
</div>
<div class="left-nav">
    <div id="side-nav">
        <ul id="nav">
        </ul>
    </div>
</div>
<div class="page-content">
    <div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="false">
        <ul class="layui-tab-title">
            <li class="home">
                <i class="layui-icon">&#xe68e;</i>首页
            </li>
        </ul>
        <div class="layui-unselect layui-form-select layui-form-selected" id="tab_right">
            <dl>
                <dd data-type="this">关闭当前</dd>
                <dd data-type="other">关闭其它</dd>
                <dd data-type="all">关闭全部</dd>
            </dl>
        </div>
        <div class="layui-tab-content" lay-filter="demo">
            <div class="layui-tab-item layui-show">
                <iframe src='/page/home' frameborder="0" scrolling="yes" tab-id="firstHomeIframe" class="x-iframe"
                        id="homeIframe"></iframe>
            </div>
        </div>
        <div id="tab_show"></div>
    </div>
</div>
<div class="page-content-bg"></div>
<style id="theme_style"></style>
</body>

<script>
    layui.use(['form', 'layer', 'element'],
        function () {
            const $ = layui.jquery;
            const layer = layui.layer;
            const element = layui.element;
            const realName = getValueByCookie("COOKIE_USER_INFO", "realName");
            const menuKeys = getValueByCookie("COOKIE_USER_INFO", "menus");
            $("#currentUserRealName").text(realName);
            if (null !== menuKeys && '' !== menuKeys) {
                const menuKeysArray = menuKeys.split(",");
                for (let j = 0; j < menuKeysArray.length; j++) {
                    //用户管理
                    if (menuKeysArray[j] === 'userManger') {
                        $("#nav").append(' <li><a href="javascript:;" layadmin-event="refresh" onclick="xadmin.add_tab(\'人员管理\',\'/page/user-list\',true)">' +
                            '<i class="iconfont left-nav-li" lay-tips="人员管理">&#xe6b8;</i><cite>人员管理</cite></a>\</li>')
                        continue;
                    }
                    //任务管理
                    if (menuKeysArray[j] === 'taskManger') {
                        $("#nav").append('<li><a href="javascript:;" onclick="xadmin.add_tab(\'任务管理\',\'/page/task-list\',true)">' +
                            '<i class="iconfont left-nav-li" lay-tips="任务管理">&#xe723;</i><cite>任务管理</cite></a></li>')
                        continue;
                    }
                    //日志管理
                    if (menuKeysArray[j] === 'taskLogManger') {
                        $("#nav").append('<li> <a href="javascript:;" onclick="xadmin.add_tab(\'操作日志\',\'/page/task-log-list\',true)"> ' +
                            '<i class="iconfont left-nav-li" lay-tips="操作日志">&#xe6ce;</i><cite>操作日志</cite></a></li>')
                    }
                }
            }

            element.on('tab(demo)', function (data) {
                //console.log("1122222" + data);
                var src = $(".layui-tab-item.layui-show").find("iframe").attr("src");
                $(".layui-tab-item.layui-show").find("iframe").attr("src", src);
            });

            //登出
            $("#loginOut").click(function () {
                //请求登出接口
                AjaxRequest.aPost(api.login_out, JSON.stringify({}), function (r) {
                    if (r.code === 0) {
                        layer.msg('退出成功', {
                            offset: '15px', icon: 1, time: 500
                        }, function () {
                            location.href = api.login;
                        });
                    } else {
                        if (r.msg !== null && r.msg !== '') {
                            ResponseMsg.errorMsg('退出失败，' + r.msg);
                        } else {
                            ResponseMsg.errorMsg('退出失败，请重试。');
                        }
                    }
                });
            });

            $("#userPersonalDetail").click(function () {
                layer.open({
                    type: 2
                    , title: '个人信息'
                    , area: ['500px', '400px']
                    , shade: 0
                    , maxmin: true
                    , content: api.user.user_person_html
                });
            });

        });
</script>
</html>